package com.huawei.appmarket.oobe.app;

import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import android.os.RemoteException;
import androidx.annotation.RequiresApi;
import com.huawei.secure.android.common.intent.SafeIntent;
import o.dkz;
import o.dld;
import o.dli;
import o.dll;
import o.dlo;
import o.Logger;
import o.doo;
import o.ContentManager;
import o.ll;

@RequiresApi(api = 26)
public class OOBEStartupGuideService extends Service {
    private b ˏ = new b(this);

    class b extends o.dlr.b {
        final /* synthetic */ OOBEStartupGuideService ˎ;

        b(OOBEStartupGuideService oOBEStartupGuideService) {
            this.ˎ = oOBEStartupGuideService;
        }

        public void ॱ() throws RemoteException {
            Logger.ˎ("OOBE", "OOBEStartupGuideInterface.notifyNetworkConfigFinished ");
            if (dli.ˏ(this.ˎ)) {
                this.ˎ.ˊ();
            }
        }

        public void ˎ() throws RemoteException {
            Logger.ˎ("OOBE", "OOBEStartupGuideInterface.notifyOOBESkipped ");
            if (dli.ˏ(this.ˎ)) {
                this.ˎ.ˎ();
            }
        }

        public boolean ˏ() throws RemoteException {
            Logger.ˎ("OOBE", "OOBEStartupGuideInterface.isOOBESupport ");
            if (!dli.ˏ(this.ˎ)) {
                return false;
            }
            boolean ᐝॱ = dld.ˎ().ᐝॱ();
            Logger.ˎ("OOBE", "OOBEStartupGuideInterface.isOOBESupport = " + ᐝॱ);
            return ᐝॱ;
        }

        public void ˊ() throws RemoteException {
            Logger.ˎ("OOBE", "OOBEStartupGuideInterface.notifyStartupGuideFinished ");
            if (dli.ˏ(this.ˎ)) {
                this.ˎ.ˏ();
            }
        }
    }

    public IBinder onBind(Intent intent) {
        Logger.ˎ("OOBE", "OOBEStartupGuideService onBind");
        SafeIntent safeIntent = new SafeIntent(intent);
        if (dli.ˏ(this)) {
            String action = safeIntent.getAction();
            if (action != null && action.equals("com.huawei.appmarket.oobe.ACTION_BIND_STARTUP_GUIDE")) {
                return this.ˏ;
            }
        }
        return null;
    }

    public boolean onUnbind(Intent intent) {
        Logger.ˎ("OOBE", "OOBEStartupGuideService onUnbind");
        return super.onUnbind(intent);
    }

    private void ˊ() {
        Logger.ˎ("OOBE", "OOBEStartupGuideInterface.doWithNetworkConfigFinished ");
        Context ˋ = ContentManager.getInstant().getContext();
        dli.ˏ("350201", dli.ʽ(ˋ));
        if (!doo.ˊ(ˋ)) {
            Logger.ˎ("OOBE", "doWithNetworkConfigFinished：no active network");
        } else if (dld.ˎ().ॱᐝ()) {
            Logger.ˎ("OOBE", "doWithNetworkConfigFinished：still querying, ignore");
        } else {
            dld.ˎ().ˎ(false);
            dld.ˎ().ॱ(false);
            dld.ˎ().ॱˎ();
            dld.ˎ().ʻ(false);
            OOBESupportService.startService();
            Intent intent = new Intent("com.huawei.appmarket.oobe.ACTION_QUEREY_IF_OOBE_SUPPORT");
            intent.setClass(ˋ, OOBEFlowController.class);
            intent.putExtra("fromWhere", 0);
            ll.ˏ(ˋ).ˋ(intent);
            dld.ˎ().ˊ(true);
        }
    }

    private void ˎ() {
        dld.ˎ().ˎ(true);
        dll.ˎ().ˏ(this);
        dli.ˏ("350204", dli.ʽ(this));
        dli.ˏ("350304", dli.ʽ(this));
    }

    private void ˏ() {
        Context ˋ = ContentManager.getInstant().getContext();
        dlo.ˎ().ॱ();
        try {
            if (dli.ˏ(ˋ)) {
                dli.ˊ(ˋ).edit().putBoolean("setupwizardFinished", true).putLong("setupwizardFinishedTime", System.currentTimeMillis()).commit();
                if (dld.ˎ().ʼॱ() == 2) {
                    dll.ˎ().ˋ(ˋ, true);
                    OOBEQueryIfSupportJobService.schedule(ˋ, 1);
                } else if (dld.ˎ().ʼॱ() == 1) {
                    dli.ˏ("350203", dli.ʽ(this));
                    OOBEExportedReceiver.doPrimaryFlowAfterSetupFinished(ˋ);
                    if (dld.ˎ().ॱॱ()) {
                        Logger.ˎ("OOBE", "doWithSetupWizardFinished prepare notification flow");
                        OOBEQueryIfSupportJobService.schedule(ˋ, 1);
                    }
                    OOBEAppListUpdateCheckJobService.schedule(ˋ);
                    dkz.ˎ();
                } else {
                    dli.ˏ("350203", dli.ʽ(this));
                    dll.ˎ().ˋ(ˋ, true);
                    OOBEQueryIfSupportJobService.schedule(ˋ, 1);
                }
                OOBESupportService.stopService();
            }
        } finally {
            OOBESupportService.stopService();
        }
    }
}
